//
//  UserAccount.m
//  youlele
//
//  Created by wujian on 2017/12/17.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "UserAccount.h"

#define AccountFilePath [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"account.data"]

@implementation UserAccount

MJCodingImplementation

+ (void)saveAccount:(UserAccount *)account
{
    // 归档
    [NSKeyedArchiver archiveRootObject:account toFile:AccountFilePath];
}

+(UserAccount *)account
{
    // 读取帐号
    UserAccount *account = [NSKeyedUnarchiver unarchiveObjectWithFile:AccountFilePath];
    
    if (!account) {
        
        account = [[UserAccount alloc] init];
    }
    
    return account;
}

@end
